<template>
  <div id="app">
    <h3>分拣主管列表</h3>
    <el-button type="primary" style="float:right;margin-bottom:10px;" @click="addsortmang()">新增分拣主管</el-button>
    <!-- 表格 -->
    <el-table
      :data="sortmangerlist"
      border
      style="width: 100%;"
      :cell-style="cellstyle"
      :header-cell-style="rowClass"
    >
      <el-table-column type="index" label="序号" />
      <el-table-column prop="name" label="分拣主管" />
      <el-table-column prop="phone" label="联系方式" />
      <el-table-column prop="sortLineName" label="分拣线" />
      <el-table-column prop="workTypeName" label="班次" />
      <el-table-column prop="workTypeName" label="每天最大产能" />
      <el-table-column label="操作" fixed="right">
        <template slot-scope="scope">
          <span class="btn edit" @click="edit(scope.row)">编辑</span>
          <span class="btn">删除</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getsortmanagerList } from '@/api/sortmanage.js'
// import VueEvent from '@/utils/VueEvent.js'
export default {
  data() {
    return {
      sortmangerlist: []
    }
  },
  mounted() {
    getsortmanagerList()
      .then(res => {
        console.log(res)
        this.sortmangerlist = res.rows
      })
      .catch(err => {
        console.log(err)
      })
  },
  methods: {
    cellstyle({ row, column, rowIndex, columnIndex }) {
      return 'text-align:center'
    },
    rowClass({ row, rowIndex }) {
      return 'text-align:center'
    },
    addsortmang() {
      this.$router.push({ path: 'addsortmang' })
    },
    edit(obj) {
      console.log(obj)
      //   VueEvent.$emit('editsort', obj)
      this.$router.push({
        path: 'editsortmang',
        query: obj
      })
    }
  }
}
</script>

<style lang="scss" scoped>
#app {
  padding: 30px 20px;
  .btn{
      cursor: pointer;
      color: #333333;
  }
  .edit{
      margin-right: 10px;
  }
}

</style>
